
#include <VirtualRobot/VirtualRobotException.h>
#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
#include <VirtualRobot/RuntimeEnvironment.h>

#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/Qt/SoQt.h>
#include <boost/shared_ptr.hpp>
#include <string>
#include <iostream>


#include <Eigen/Core>
#include <Eigen/Geometry>
#include "MMMConverterGUIWindow.h"
#include <MMM/Motion/Legacy/LegacyMotionReaderXML.h>
#include <MMM/Motion/Legacy/LegacyMotionReaderC3D.h>
#include <MMM/Model/ModelReaderXML.h>
#include <MMM/Motion/Legacy/Converter/ConverterFactory.h>

#include "../common/ConverterApplicationHelper.h"
#include "MMMConverterGuiConfiguration.h"
#include "MMMConverterGuiConfiguration.cpp"

using std::cout;
using std::endl;
using namespace VirtualRobot;

// exemplary command line options
// --converterConfigFile "../data/ConverterVicon2MMM_WinterConfig.xml" --converter "ConverterVicon2MMM" --outputModelProcessorConfigFile "../data/ModelProcessor_Winter_1.70.xml" --outputModelProcessor "Winter" --outputModel "../data/Model/Winter/mmm.xml" --inputDataVicon "../data/Motions/BendingLeftArm 1.c3d"
// --converterConfigFile "../data/ConverterVicon2MMM_BottleConfig.xml" --converter "RigidBodyConverterVicon2MMM" --outputModelProcessorConfigFile "" --outputModelProcessor "" --outputModel "../data/Model/Objects/Bottle/Bottle.xml" --inputDataVicon "../data/Motions/FetchBottle 7.c3d"
// --converterConfigFile "../data/ConverterVicon2MMM_BowlConfig.xml" --converter "RigidBodyConverterVicon2MMM" --outputModelProcessorConfigFile "" --outputModelProcessor "" --outputModel "../data/Model/Objects/OrangeBowl/Bowl201407.xml" --inputDataVicon "../data/Motions/FetchBottle 7.c3d"
// --converterConfigFile "../data/ConverterVicon2MMM_WinterConfig.xml" --converter "ConverterVicon2MMM" --outputModelProcessorConfigFile "../data/ModelProcessor_Winter_1.70.xml" --outputModelProcessor "Winter" --outputModel "../data/Model/Winter/mmm.xml" --inputDataVicon "../data/Motions/FetchBottle 7.c3d"
// --converterConfigFile "../data/ConverterVicon2MMM_WinterConfig.xml" --converter "ConverterVicon2MMM" --outputModelProcessorConfigFile "../data/ModelProcessor_Winter_1.80.xml" --outputModelProcessor "Winter" --outputModel "../data/Model/Winter/mmm.xml" --inputDataVicon "../data/Motions/walking_slow02.c3d"
// --converterConfigFile "../data/ConverterVicon2MMM_WinterConfig.xml" --converter "ConverterVicon2MMM" --outputModelProcessorConfigFile "../data/ModelProcessor_Winter_1.80.xml" --outputModelProcessor "Winter" --outputModel "../data/Model/Winter/mmm.xml" --inputFile "../data/Motions/step_stones08.c3d"


int main(int argc, char *argv[])
{
	SoDB::init();
	SoQt::init(argc,argv,"MMMConverterGUI");

	cout << " --- MMMConverterGUI --- " << endl;
    if ((argc==2) && (std::string(argv[1]).compare("--help") == 0) )
    {
        // todo: adapt help text to new changes
        std::cout << "Use the following syntax: (todo)" << std::endl;
        /*
        std::cout << "MMMConverterGUI --<parameter> <value>" << std::endl
                  << "where" << std::endl
                  << "<parameter>\t\t<value>" << std::endl \
                  << "converterConfigFile\tXML file containing converter configurations" << std::endl
                  << "converter\t\tName of the converter to use, for example 'RigidBodyConverterVicon2MMM'" << std::endl
                  << "outputModel\t\tXML file for the target model" << std::endl
                  << "inputDataVicon\t\tC3D file, containing the recorded marker data" << std::endl;
                  */
                     /*
                     --outputModelProcessorConfigFile ""
                     --outputModelProcessor ""
                     --outputModel "/home/SMBAD/terlemez/local/intern/model/objects/Beam/beam.xml"
                     --inputDataVicon "/home/SMBAD/terlemez/local/intern/model/objects/Beam/test.c3d"*/
        return 0;
    }
    MMMConverterGuiConfiguration c;
    if (!c.processCommandLine(argc,argv))
    {
        MMM_ERROR << "Error processing command line, aborting..." << endl;
        return -1;
    }
    c.print();

    //MMMConverterGUIWindow mgw(c.modelFileTarget, c.dataFileSource, c.modelProcessorNameTarget, c.modelProcessorConfigFileTarget, c.converterName, c.converterConfigFile);
    MMMConverterGUIWindow mgw(c.inputFile, c.sourceModelFile, c.targetModelFile, c.sourceModelProcessor, c.targetModelProcessor, c.sourceModelProcessorConfigFile, c.targetModelProcessorConfigFile, c.converterName, c.converterConfigFile, c.markerPrefix);

    mgw.main();


	cout << " --- END --- " << endl;
	return 0;
}
